package org.dandsoft.blackbox;

import java.io.Serializable;

/**
 * @author Vilyuzhanin Denis (Fin)
 */
public class Time implements Serializable {
    public final static Time NULL = new Time(0);

    private long value;

    public Time(long value) {
        this.value = value;
    }

    public long getValue() {
        return value;
    }

    public Time increment() {
        return new Time(value += 1);
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("Time");
        sb.append("{value=").append(value);
        sb.append('}');
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Time time = (Time) o;

        if (value != time.value) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return (int) (value ^ (value >>> 32));
    }
}
